#include <QCoreApplication>
#include <iostream>
#include <cstdlib>
#include <climits>
#include <algorithm>
using namespace std;

void sortirovka1(int* mass,int size, int sposob)
{
    if (sposob==1)
    {
        for (int i=0; i<size; i++)
            for (int j=i+1; j<size; j++)
                if (mass[i]<mass[j])
                {
                        int d=mass[i];
                        mass[i]=mass[j];
                        mass[j]=d;
                }
    }
    else if (sposob==2)
    {
        for (int i=0; i<size; i++)
            for (int j=i+1; j<size; j++)
                if (mass[i]>mass[j])
                {
                        int d=mass[i];
                        mass[i]=mass[j];
                        mass[j]=d;
                }
    }


}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    int size;
    cout<<"Vvedite razmernost massiva: ";
    cin>>size;
    int* mass=new int[size-1];
    for (int i=0; i<size; i++)
        mass[i]=rand();
    cout<<"Vash massiv\n";
    for (int i=0; i<size; i++)
        cout<<mass[i]<<" ";
    cout<<endl;
    cout<<"Viberite sposob sortirovki: 1-po ubyvaniyu, 2-po vozrastaniyu: ";
    int sposob;
    cin>>sposob;
    sortirovka1(mass, size, sposob);
    cout<<"Otsortirovanny massiv: ";
    for (int i=0; i<size; i++)
        cout<<mass[i]<<" ";

    return a.exec();
}
